package com.wj.jiangan.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wj.jiangan.mapper.EmpMapper;
import com.wj.jiangan.pojo.Emp;
import com.wj.jiangan.pojo.vo.EmpAndPart;
import com.wj.jiangan.service.IEmpService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author wj
 * @since 2019-11-05
 */
@Service
public class EmpServiceImpl implements IEmpService {

    @Autowired
    private EmpMapper empMapper;


    @Override
    public List<Emp> findEmpByPid(int pid) {
        QueryWrapper<Emp> qw = new QueryWrapper<>();
        qw.eq("p_id", pid);
        return empMapper.selectList(qw);
    }

    @Override
    public IPage<Emp> findEmpByPage(Page<Emp> page) {
        QueryWrapper<Emp> emp = new QueryWrapper<>();
        return empMapper.selectPage(page, emp);
    }

    @Override
    public List<Map<String, Object>> getEmpLineChart(Integer pid, Integer eid) {
        List<Map<String, Object>> list = empMapper.getEmpLineChart(pid, eid);
        return list;
    }

    @Override
    public List<Object> queryEmpByid(Integer pid) {
        QueryWrapper<Emp> qw = new QueryWrapper<>();
        qw.eq("p_id",pid);
        //qw.select("r_id");
        List<Object> objects = empMapper.selectObjs(qw);
        return objects;
}

    @Override
    public void updateEmpIS(Emp emp, QueryWrapper queryWrapper) {
        empMapper.update(emp,queryWrapper);
    }

    @Override
    public IPage<EmpAndPart> findEmpAndPartQuery(Page page, Map<String, Object> maps) {
        Integer pid=(Integer) maps.get("pid");
        return empMapper.getEmpAndPart(page,pid);
    }

    @Override
    public List<Emp> getEmpById() {
        return empMapper.getEmpById();
    }

    @Override
    public List<Emp> insertEmp(Emp emp) {
        return empMapper.insertEmp(emp);
    }
}
